import React, { useState, useEffect } from 'react';
import styles from './TodoButton.module.css'
console.log(styles)

// const TodoButton = ({onClick, type, children}) => {
const TodoButton = (props) => {
  const [className, setClassName] = useState([styles.btn_default])
  const onClickHandler = () => {
    props.onClick && props.onClick()
  }

  useEffect(() => {
    if (props.type === 'primary') {
      setClassName([...className, styles.btn_primary]);
    }
  }, [])

  return (
    <button className={className.join(' ')} onClick={onClickHandler}>
      {props.children ? props.children : '按钮'}
    </button>
  )
}

export default TodoButton